package com.qianfeng.zmt.controller;

import com.qianfeng.entity.dto.Goods;
import com.qianfeng.entity.po.LoginMerchant;
import com.qianfeng.entity.vo.MyPage;
import com.qianfeng.service.impl.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @RequestMapping("list")
    public String list(Model model , LoginMerchant loginMerchant ,
                       @RequestParam(value = "pageNum" , required = false , defaultValue = "1") Long pageNum){

        MyPage<Goods> myPage = goodsService.getUppedByMerchantId(loginMerchant.getId(), pageNum);

        model.addAttribute("goodsList" , myPage.getObjList());
        model.addAttribute("pageList" , myPage.getPageList());
        return "goods/list";
    }
}
